package com.hibernate.learn.models;

import javax.persistence.*;
import java.math.BigDecimal;

@Entity
@Table(name = "users")
public class User {

    public User() {}

    public User(String name, int age) {
        setAge(age);
        setName(name);
    }

    @Deprecated
    public User(String name, int age, BigDecimal amount) {
        setAge(age);
        setName(name);
//        setAmount(amount);
    }

    public User(String name, int age, int id) {
        setAge(age);
        setName(name);
        setId(id);
    }


    /* Entities */
    @Id
    @GeneratedValue // (strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false, updatable = false)
    private int user_id;

    @Column(name = "name", nullable = false)
    private String name;

    @Column(name = "age", nullable = false)
    private int age;

    /*@Column(precision = 5, scale = 1) // not need: nullable = true, updatable = true
    private BigDecimal amount;*/

    // if you need field which will not be save in db write this annotation
    @Transient
    private int forTest;

    @Override
    public String toString() {
        return "User{" +
                "user_id=" + getId() +
                ", name='" + getName() + '\'' +
                ", age=" + getAge() +
                '}';
    }

    /* Getters and setters */
    public void setId(int id) {
        this.user_id = id;
    }
    public int getId() {
        return user_id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }

    /*public BigDecimal getAmount() {
        return amount;
    }
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }*/
}